package com.wc.算法提高课.E第五章_数学知识.同余.青蛙的约会;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/10/9 14:17
 * @description https://www.acwing.com/problem/content/224/
 */
public class Main {
    /**
     * 思路：<p>
     * 假定 a为 A的初始位置, b 为 B的初始位置, m, n 分别为速度, x 为相遇的所需要走的次数, y 表示饶了几圈<p>
     * (b - a) + y * L= (n - m) * x <p>
     * (m - n) * x  - L * y = b - a <p>
     * 等价于 ax + by = gcd(a, b) , b - a 为 a, b 的最大公约数的倍数
     * ax * c + b * c y = c * gcd(a, b)
     * 背景:<p>
     *
     * @see com.wc.算法提高课.E第五章_数学知识.同余.同余方程
     */
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        long a = sc.nextInt(), b = sc.nextInt(), m = sc.nextInt(), n = sc.nextInt(), L = sc.nextInt();
        long[] x = new long[1], y = new long[1];
        long d = exgcd(m - n, L, x, y);
        if ((b - a) % d != 0) out.println("Impossible");
        else {
            x[0] = x[0] * (b - a) / d;
            long t = Math.abs(L / d);
            out.println((x[0] % t + t) % t);
        }
        out.flush();
    }

    static long exgcd(long a, long b, long[] x, long[] y) {
        if (b == 0) {
            x[0] = 1;
            y[0] = 0;
            return a;
        }
        long d = exgcd(b, a % b, y, x);
        y[0] -= a / b * x[0];
        return d;
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}
